package com.nmsl.medicine.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.medicine.domain.StorageInDetailRecord;
import com.nmsl.medicine.service.IStorageInDetailRecordService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 入库详情记录Controller
 * 
 * @author ruoyi
 * @date 2025-02-19
 */
@RestController
@RequestMapping("/medicine/recordinfo")
public class StorageInDetailRecordController extends BaseController
{
    @Autowired
    private IStorageInDetailRecordService storageInDetailRecordService;

    /**
     * 查询入库详情记录列表
     */
    @PreAuthorize("@ss.hasPermi('medicine:recordinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(StorageInDetailRecord storageInDetailRecord)
    {
        startPage();
        List<StorageInDetailRecord> list = storageInDetailRecordService.selectStorageInDetailRecordList(storageInDetailRecord);
        return getDataTable(list);
    }

    /**
     * 导出入库详情记录列表
     */
    @PreAuthorize("@ss.hasPermi('medicine:recordinfo:export')")
    @Log(title = "入库详情记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StorageInDetailRecord storageInDetailRecord)
    {
        List<StorageInDetailRecord> list = storageInDetailRecordService.selectStorageInDetailRecordList(storageInDetailRecord);
        ExcelUtil<StorageInDetailRecord> util = new ExcelUtil<StorageInDetailRecord>(StorageInDetailRecord.class);
        util.exportExcel(response, list, "入库详情记录数据");
    }


    /**
     * 新增入库详情记录
     */
    @PreAuthorize("@ss.hasPermi('medicine:recordinfo:add')")
    @Log(title = "入库详情记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StorageInDetailRecord storageInDetailRecord)
    {
        return toAjax(storageInDetailRecordService.insertStorageInDetailRecord(storageInDetailRecord));
    }

    /**
     * 修改入库详情记录
     */
    @PreAuthorize("@ss.hasPermi('medicine:recordinfo:edit')")
    @Log(title = "入库详情记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StorageInDetailRecord storageInDetailRecord)
    {
        return toAjax(storageInDetailRecordService.updateStorageInDetailRecord(storageInDetailRecord));
    }

    /**
     * 删除入库详情记录
     */
    @PreAuthorize("@ss.hasPermi('medicine:recordinfo:remove')")
    @Log(title = "入库详情记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{storageInDetailIds}")
    public AjaxResult remove(@PathVariable Long[] storageInDetailIds)
    {
        return toAjax(storageInDetailRecordService.deleteStorageInDetailRecordByStorageInDetailIds(storageInDetailIds));
    }
}
